package org.jeecg.modules.cosmetic.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.cosmetic.handler.ToxicologicalHandler;
import org.jeecg.modules.cosmetic.model.vo.*;
import org.jeecg.modules.cosmetic.utils.MyValidateUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;


/**
 * <p>
 * 毒理数据库表 前端控制器
 * </p>
 *
 * @author lq
 * @since 2024-02-29 13:57:47
 */
@Api(tags = "毒理数据")
@RestController
@RequestMapping("/api/tox")
public class TToxicologicalController {

    @Resource
    private ToxicologicalHandler toxicologicalHandler;

    @ApiOperation(value = "列表分页", notes = "列表分页")
    @PostMapping(value = "/page")
    public Result<?> getPage(@RequestBody ToxPageVO vo) {
        MyValidateUtil.validThrow(vo);
        return toxicologicalHandler.getPage(vo);
    }

    @ApiOperation(value = "新增原料", notes = "新增原料")
    @PostMapping(value = "/save")
    public Result<?> saveRaw(@RequestBody ToxRawVO vo) {
        MyValidateUtil.validThrow(vo);
        return toxicologicalHandler.saveRaw(vo);
    }

    @ApiOperation(value = "更新标识信息-可用浓度-KCII信息", notes = "更新标识信息-可用浓度-KCII信息")
    @PutMapping(value = "/update")
    public Result<?> updateTox(@RequestBody ToxModuleVO vo) {
        MyValidateUtil.validThrow(vo);
        return toxicologicalHandler.updateTox(vo);
    }

    @ApiOperation(value = "查询毒理数据主表数据", notes = "查询毒理数据主表数据")
    @GetMapping(value = "/get")
    public Result<?> getTox(@RequestParam("id") Long id) {
        return Result.ok(toxicologicalHandler.getTox(id));
    }

    @ApiOperation(value = "查询毒理数据数据详情", notes = "查询毒理数据数据详情")
    @GetMapping(value = "/detail")
    public Result<?> getToxDetail(@RequestParam("id") Long id) {
        return Result.ok(toxicologicalHandler.getTox(id));
    }

    @ApiOperation(value = "删除数据", notes = "删除数据")
    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestBody DeleteVO vo) {
        return Result.ok(toxicologicalHandler.delete(vo.getId()));
    }

    @ApiOperation(value = "更新IECIC备注信息", notes = "更新IECIC备注信息")
    @PutMapping(value = "/update_remark")
    public Result<?> updateRemark(@RequestBody IecicRemarkVO vo) {
        MyValidateUtil.validThrow(vo);
        return toxicologicalHandler.updateRemark(vo);
    }

    @ApiOperation(value = "上传文件", notes = "上传文件")
    @PostMapping(value = "/upload")
    public Result<?> upload(@RequestParam(value = "file") MultipartFile file) {
        return toxicologicalHandler.upload(file);
    }
}
